import sys

import wx

from view_data.utils import setup_logger
from view_data.controller import Controller

if __name__ == '__main__':
    setup_logger()
    app = wx.PySimpleApp()

    controller = Controller()
    controller.setup()
    controller.setup_subscriptions()
    
    # check to see if a path was supplied at the command line, if so
    #   automatically add the database found there to the tree_panel.
    import sys
    dbpath = None
    for arg in sys.argv:
        if '-dbp' == arg:
            dbpath = sys.argv[sys.argv.index(arg)+1]
        if '--dbpath' in arg:
            junk, dbpath = arg.split('=')
    if dbpath is not None:
        controller.model.open_database(dbpath)

    app.MainLoop()
